﻿using System;
using System.Collections.Generic;
using ATSBLL;
using CrystalDecisions.CrystalReports.Engine;
using ATSModel;

public partial class TestDataReport_ElectReport_ElecProperty : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        this.CrystalReportSource1.ReportDocument.Load(Server.MapPath("ElecProperty.rpt"));
        IList<ElecPropertyInfo> list = GetDataByDate();

        this.CrystalReportSource1.ReportDocument.SetDataSource(list);
        this.CrystalReportSource1.DataBind();
        this.CrystalReportViewer1.ReportSource = CrystalReportSource1;
        this.CrystalReportViewer1.DataBind();
        this.CrystalReportViewer1.Visible = true;
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        this.CrystalReportSource1.ReportDocument.Load(Server.MapPath("ElecProperty.rpt"));
        IList<ElecPropertyInfo> list = GetData();

        this.CrystalReportSource1.ReportDocument.SetDataSource(list);
        this.CrystalReportSource1.DataBind();
        this.CrystalReportViewer1.ReportSource = CrystalReportSource1;
        this.CrystalReportViewer1.DataBind();
        this.CrystalReportViewer1.Visible = true;
    }

    protected  IList<ElecPropertyInfo> GetDataByDate()
    {
        DateTime dt1 = DateTime.Parse(this.TextBox1.Value.Trim());
        DateTime dt2 = DateTime.Parse(this.TextBox2.Value.Trim());

        IList<ElecPropertyInfo> testItems = new List<ElecPropertyInfo>();
        Report_ElecProperty elect = new Report_ElecProperty();

        testItems = elect.GetElecData(dt1, dt2);
        return testItems;
    }

    protected IList<ElecPropertyInfo> GetData()
    {
        IList<ElecPropertyInfo> testItems = new List<ElecPropertyInfo>();
        Report_ElecProperty elect = new Report_ElecProperty();

        testItems = elect.GetElecData();
        return testItems;
    }
}
